package com.ktg.mes.wm.domain;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;
import com.ktg.mes.unit.sql.service.SQLToolService;
import lombok.Data;
import lombok.experimental.Accessors;

import java.math.BigDecimal;


@Accessors(chain = true)
@TableName("wm_quantity_record")
public class WmQuantityRecord extends BaseEntity
{
    private static final long serialVersionUID = 1L;


    /**
     * 类型  1-排产记录入库
     */
    private Integer type;

    /** 库存表 */
    @Excel(name = "库存表")
    private String stockType;


    /** 库存ID */
    @Excel(name = "库存ID")
    private String stockId;


    /** 关联表 */
    @Excel(name = "使用物料的表名")
    private String linkType;


    /** 关联ID */
    @Excel(name = "使用物料的表ID")
    private String linkId;

    /** 预出库数量 */
    @Excel(name = "预出库数量")
    private BigDecimal quantity;


    /**
     * sum总数
     */
    private BigDecimal allAuantity;


    /**
     * 设置库存记录
     * @param c
     * @param stockId
     */
    public void stockTableClass(QuantityRecordType type,Class<?> c,Long stockId){
        stockTableClass(type,c,String.valueOf(stockId));
    }

    /**
     * 设置为了谁预出
     * @param c
     * @param linkId
     */
    public void linkTableClass(Class<?> c,Long linkId){
        linkTableClass(c,String.valueOf(linkId));
    }


    /**
     * 设置库存记录
     * @param c
     * @param stockId
     */
    public void stockTableClass(QuantityRecordType type,Class<?> c,String stockId){
        this.type = type.value;
        String tableName =  c.getAnnotation(TableField.class).value();
        this.stockType = tableName;
        this.stockId = stockId;
    }

    /**
     * 设置为了谁预出
     * @param c
     * @param linkId
     */
    public void linkTableClass(Class<?> c,String linkId){
        String tableName =  c.getAnnotation(TableField.class).value();
        this.linkType = tableName;
        this.linkId = linkId;
    }

    public enum QuantityRecordType{
        //排产任务入库数量记录
        TaskInStock(1);


        private Integer value;
        QuantityRecordType(Integer value){
            this.value = value;
        }
    }




}
